const path = require('path')
const fs = require("fs")

//utf-8 不适合读取视频和音频，默认是2进制
//流文件，专门针对大文件的读取，会覆盖原来的文件
let readfiles = fs.createReadStream(path.resolve(__dirname, "./img/0.png"))  //读
let writefiles = fs.createWriteStream(path.resolve(__dirname, "./img/copy.png")) //写，没有目录会自动生成

writefiles.on("open", function () {
    console.log("文件打开")
})
//这个最后才会执行
readfiles.on("close", function () {
    console.log("文件关闭")
})

readfiles.pipe(writefiles)

